#ifndef __NONAME_FILE_H__
#define __NONAME_FILE_H__

#define NONAME_LIB_USE

#include <Ntifs.h>
#include "nm_mem.h"
#include "nm_string.h"

#define FILE_BEGIN		0
#define FILE_CURRENT	1
#define FILE_END		2

class kfile {

public:
	kfile();
	void Release();

	VOID Close();
	NTSTATUS Create(
		kstringw& FileName, 
		ULONG  CreateDisposition = FILE_OPEN, 
		ACCESS_MASK DesiredAccess = GENERIC_READ, 
		ULONG ShareAccess = FILE_SHARE_READ
		);
	NTSTATUS Create(
		PWCHAR FileName, 
		ULONG  CreateDisposition = FILE_OPEN, 
		ACCESS_MASK DesiredAccess = GENERIC_READ, 
		ULONG ShareAccess = FILE_SHARE_READ
		);
	NTSTATUS Create(
		PUNICODE_STRING FileName, 
		ULONG  CreateDisposition = FILE_OPEN, 
		ACCESS_MASK DesiredAccess = GENERIC_READ, 
		ULONG ShareAccess = FILE_SHARE_READ
		);
	NTSTATUS Delete(BOOLEAN Del = TRUE);
	NTSTATUS Flush();
	HANDLE GetHandle();
	NTSTATUS GetName(kstringw& String);
	PFILE_OBJECT GetObject();
	NTSTATUS GetPath(kstringw& String);
	NTSTATUS GetPath(PFILE_NAME_INFORMATION NameInfo, ULONG Length);
	NTSTATUS GetSize(PLARGE_INTEGER FileSize);
	NTSTATUS Read(PVOID Buffer, ULONG Length, PULONG RetLength = NULL);
	NTSTATUS Rename(PFILE_RENAME_INFORMATION RenameInfo, ULONG Length);
	NTSTATUS Rename(kstringw& Name, BOOLEAN ReplaceIfExists = FALSE);
	BOOLEAN SetPointer(PLARGE_INTEGER DistanceToMove, ULONG Flag = FILE_BEGIN, PLARGE_INTEGER NewPointer = NULL);
	NTSTATUS SetEnd(PLARGE_INTEGER EndPos);
	NTSTATUS Write(PVOID Buffer, ULONG Length, PULONG RetLength = NULL);
	

private:
	HANDLE m_filehandle;
	PFILE_OBJECT m_fileobj;
};

#endif